function getUserInfo() {
    $.ajax({
        url: '/my/userinfo',
        success: function (res) {
            layui.form.val('user-form', res.data)

        }
    })
}

getUserInfo()

layui.form.verify({
    nickname: [/^[\S]{1,10}$/, '请输入1-10位非空字符串']
})

$('form').on('submit', function (e) {
    e.preventDefault()

    $.ajax({
        url: '/my/userinfo',
        method: 'PUT',
        data: $(this).serialize(),
        success: function (res) {
            if (res.code === 0) {
                window.parent.getUserInfo()
            }
            layui.layer.msg(res.message)
        }
    })
})

$('.reset').on('click', function () {
    getUserInfo()
})